home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Developer Utilities / Installer 4.0.3 SDK / Script Examples / System Rules - Application / appRules.r < prev    next >
Encoding:
Text File  |  1994-11-15  |  12.3 KB  |  433 lines  |  [TEXT/MPS ]

  1. //
  2. //    appRules.r
  3. //
  4. //        This example demonstrates usage of the Easy and Custom Install 
  5. //        frameworks for use in installing an application.
  6. //
  7. //        System version screening, as well as customized user interface and 
  8. //        installation contents based on existing system version of selected 
  9. //        target volume are included.
  10. //
  11. //        All files are installed to folder "System Rules App Example:" on 
  12. //        root folder of selected target volume for the installation.
  13. //
  14. //         IMPORTANT: It should be noted that this example portrays TeachText 
  15. //        as having system requirements of 7.0 or 7.5, in addition to the claim
  16. //        that System 6 is not supported. There is no factual basis for this 
  17. //        portrayal. TeachText is used only as an example and has not mutated
  18. //        were not looking.
  19. //
  20. //
  21. //        mark young • 08/24/94
  22. //
  23. //        Copyright 1993-1994, Apple Computer, Inc., All Rights Reserved
  24. //
  25.  
  26. #include "InstallerTypes.r"
  27.  
  28.  
  29. // constants for packages, comments, comment text
  30. #define     k75Package            100
  31. #define     k70Package            200
  32. #define     kSeperatorLine        9999
  33.  
  34. // target spec of system file for comparing system versions
  35. #define     kSystemFileTarget     20001
  36.  
  37.  
  38.  
  39.  
  40. // • easy install setup
  41.  
  42. // easy install framework uses ID other than 765 or 766
  43. // recommended to always use ID 764
  44. resource 'infr' (764) {
  45.     format0 {{
  46.         // execute first true rule, if none are true then return false
  47.         pickFirst, { 700, 800, 900 }, // check system version, if bad give error
  48.     }}
  49. };
  50.  
  51. // rule that adds 7.5 or greater compatable file to Easy Install
  52. resource 'inrl' (700) {
  53.     format0 {{
  54.         // check for 7.5 or greater
  55.         CheckFileVersion{ kSystemFileTarget, 7, 5, release, 0 },
  56.         
  57.         // if 7.5 or greater add that package
  58.         AddPackages{{ k75Package }},
  59.         AddUserDescription{ "Install 7.5 compatable version of TeachText." },
  60.     }}
  61. };
  62.  
  63. // rule that adds 7.0 or greater compatable file to Easy Install
  64. resource 'inrl' (800) {
  65.     format0 {{
  66.         // check for 7.0 or greater
  67.         CheckFileVersion{ kSystemFileTarget, 7, 0, release, 0 },
  68.         
  69.         // if 7.0 or greater add that package
  70.         AddPackages{{ k70Package }},
  71.         AddUserDescription{ "Install 7.0 compatable version of TeachText." },
  72.     }}
  73. };
  74.  
  75.  
  76. // • custom install setup
  77.  
  78. // custom install framework always uses ID of 766
  79. resource 'infr' (766) {
  80.     format0 {{
  81.         pickFirst, { 1000, 900 },  // check system version, if bad give error
  82.     }}
  83. };
  84.  
  85. // rule that checks system version of target volume
  86. resource 'inrl' (1000) {
  87.     format0 {{
  88.         // this returns false unless system version is greater than 7.0
  89.         CheckFileVersion{ kSystemFileTarget, 7, 0, release, 0 },
  90.         AddCustomItems{{ k75Package, kSeperatorLine, k70Package }},
  91.     }}
  92. };
  93.  
  94. // • used in both easy and custom
  95. resource 'inrl' (900) {
  96.     format0 {{
  97.         ReportVolError{ "System 7.0 or greater required for installation !!" }
  98.     }}
  99. };
  100.  
  101.  
  102. // • packages
  103.  
  104. // 7.5 or greater
  105. resource 'inpk' ( k75Package ) {
  106.     format0 {
  107.         showsOnCustom,    // if a subpackage, then show in Custom Install
  108.         removable,        // include package or subpackage as a removeable item
  109.         dontForceRestart,// don't make user reboot his computer after install
  110.         k75Package,        // ID of package comments ( 'inpc' ) rsrc defined below
  111.         0,                // Package size ( if 0, filled in by ScriptCheck )
  112.         
  113.         "7.5 compatable version of TeachText.",        
  114.                         // Custom Install selection text
  115.                                 
  116.                                 
  117.         {                // Package parts list ( all the stuff to be included 
  118.                         // in package ) These parts can be 'inpk', 'infa', 'inra', 
  119.                         // 'inr#', 'inrm', 'inff', 'infm', 'inaa', 'inat', 'inat', 
  120.                         // or 'inbb'
  121.                                                                 
  122.         'infa', 1075;    // 7.5 compatable file
  123.         },
  124.     }
  125. };
  126.  
  127.  
  128. // seperator line in Custom Install list of options
  129. resource 'inpk' ( kSeperatorLine ) {
  130.     format0 {
  131.         showsOnCustom,    // if a subpackage, then show in Custom Install
  132.         removable,        // include package or subpackage as a removeable item
  133.         dontForceRestart,// don't make user reboot his computer after install
  134.         0,                // no comments for a seperator line
  135.         0,                // no size for a seperator line
  136.         "-",            // display dashed line in Custom Install list of options
  137.         {    
  138.                         // parts list is empty for seperator line
  139.         },
  140.     }
  141. };
  142.  
  143. // 7.5 or greater
  144. resource 'inpk' ( k70Package ) {
  145.     format0 {
  146.         showsOnCustom,    // if a subpackage, then show in Custom Install
  147.         removable,        // include package or subpackage as a removeable item
  148.         dontForceRestart,// don't make user reboot his computer after install
  149.         k70Package,        // ID of package comments ( 'inpc' ) rsrc defined below
  150.         0,                // Package size ( if 0, filled in by ScriptCheck )
  151.         
  152.         "7.0 compatable version of TeachText.",        
  153.                         // Custom Install selection text
  154.                                 
  155.                                 
  156.         {                // Package parts list ( all the stuff to be included 
  157.                         // in package ) These parts can be 'inpk', 'infa', 'inra', 
  158.                         // 'inr#', 'inrm', 'inff', 'infm', 'inaa', 'inat', 'inat', 
  159.                         // or 'inbb'
  160.                                                                 
  161.         'infa', 1070;    // 7.0 compatable file
  162.         },
  163.     }
  164. };
  165.  
  166.  
  167.  
  168. // • package comments
  169.  
  170. // NOTE: The actual file that will be installed in either package is actually 
  171. // TeachText. The information detailed below does not actually correspond to  
  172. // the file being installed and is intended only as an example of how to  
  173. // prepare custom package information resources.
  174.  
  175. // FURTHER NOTE: The values that are assigned to the Custom Package Information 
  176. // resource
  177. // fields do not actually have any effect on the installation and are ignored
  178. // during installation. They can however assist the user in choosing which 
  179. // packages they would like to include in their Custom Installation or Custom 
  180. // Removal.
  181.  
  182. // The following included file contains the icons for the two package comments.
  183. // I created the file with the icon resources ( 'ICN#, 'icl4' and 'icl8' )
  184. // by opening the application to be installed within ResEdit. I then copied 
  185. // the 'ICN#', 'icl4' and 'icl8' icon resources into a new ResEdit file called 
  186. // "Icons.rsrc" and assigned the resource items an ID of 9128, since their
  187. // original resource ID's had a value that was illegal for use with 'inpc' 
  188. // resources ( they must be over 1024 ).
  189. // - An alternative to this method is to derez the application and to paste 
  190. // the resulting resource definitions into this script file and to let the 
  191. // Rez command build the icons every time that the installer script is Rezzed. 
  192. // If you happen to forget to include the resources for the icons, ScriptCheck 
  193. // will complain, but you will still be able to use the Rezzed installer script 
  194. // to successfully perform an installation. 
  195. include "Icons.rsrc";
  196.  
  197. resource 'inpc' ( k75Package ) {
  198.     format1 {
  199.         8021994,                // sample date ( 08/02/94 )
  200.         403,                    // sample version ( 4.0.3 )
  201.         
  202.         2500 * 1024,            // RAM required for package ( 2.5 megabytes )
  203.         
  204.         9128,                    // icon rsrc ID ( 'ICN#', 'icl4', 'icl8' )
  205.                                 // - ID must be greater than 1024
  206.                                 // - resource item in rezzed script file
  207.                                 
  208.         k75Package,                // 'TEXT' resource ID of item  
  209.                                 // containing package description
  210.         
  211.     }
  212. };
  213.  
  214. resource 'inpc' ( k70Package ) {
  215.     format1 {
  216.         8021994,                // sample date ( 08/02/94 )
  217.         403,                    // sample version ( 4.0.3 )
  218.  
  219.         4250 * 1024,            // RAM required for package ( 4.25 megabytes )
  220.         
  221.         9128,                    // icon rsrc ID ( 'ICN#', 'icl4', 'icl8' )
  222.                                 // - ID must be greater than 1024
  223.                                 // - resource item in rezzed script file
  224.  
  225.         k70Package,            // 'TEXT' resource ID of item  
  226.                                 // containing package description
  227.     }
  228. };
  229.  
  230.  
  231. // The following resource items can easily be created manually by creating 'TEXT' 
  232. //  resource items in a file and including that file in this script.
  233. // USE: include "fileWithTextItem.rsrc";    
  234. // NOTE : resource includes use "include" instead of "#include" 
  235. //         and are terminated with a semicolon.
  236. data 'TEXT' ( k75Package ) {
  237.     "This is some sample text that would describe what "
  238.     "the 7.5 compatible package contains."
  239. };
  240.  
  241. data 'TEXT' ( k70Package ) {
  242.     "This is some sample text that would describe what "
  243.     "the 7.0 compatible package contains."
  244. };
  245.  
  246.  
  247.  
  248. // • file atoms
  249.  
  250. // file atom for extension
  251. resource 'infa' (1075) {
  252.     format1 {
  253.         deleteWhenRemoving,
  254.         deleteWhenInstalling,
  255.         copy,                        
  256.         dontIgnoreLockedFile,
  257.         dontSetFileLocked,
  258.         useSrcCrDateToCompare,        
  259.         srcNeedExist,
  260.         rsrcForkInRsrcFork,
  261.         leaveAloneIfNewer,            
  262.         updateExisting,                
  263.         copyIfNewOrUpdate,
  264.         rsrcFork,
  265.         dataFork,
  266.         0,
  267.         0x0,
  268.         10075,
  269.         {    
  270.             10076, 
  271.             0, 
  272.             0    
  273.         },
  274.         0,                            
  275.         0,
  276.         0,
  277.         "TeachText • 7.5"
  278.     }
  279. };
  280.  
  281. // file atom for extension
  282. resource 'infa' (1070) {
  283.     format1 {
  284.         deleteWhenRemoving,
  285.         deleteWhenInstalling,
  286.         copy,                        
  287.         dontIgnoreLockedFile,
  288.         dontSetFileLocked,
  289.         useSrcCrDateToCompare,        
  290.         srcNeedExist,
  291.         rsrcForkInRsrcFork,
  292.         leaveAloneIfNewer,            
  293.         updateExisting,                
  294.         copyIfNewOrUpdate,
  295.         rsrcFork,
  296.         dataFork,
  297.         0,
  298.         0x0,
  299.         10070,
  300.         {    
  301.             10071, 
  302.             0, 
  303.             0    
  304.         },
  305.         0,                            
  306.         0,
  307.         0,
  308.         "TeachText • 7.0"
  309.     }
  310. };
  311.  
  312.  
  313. // • file specs
  314.  
  315. // target file spec  TeachText application for 7.5
  316. resource 'intf' (10075) {
  317.     format1 {
  318.         noSearchForFile,             // use default search path
  319.         
  320.         TypeCrMustMatch,             // If this is set to TypeCrMustMatch
  321.                                     // then a file with a different type
  322.                                     // and creator than those specified
  323.                                     // below will not be replaced.
  324.                                     // If this is set to TypeCrNeedNotMatch
  325.                                     // then type and creator of an existing
  326.                                     // target file are ignored.
  327.         
  328.         // The Type and Creator fields will be used to set the
  329.         // file's Type and Creator when a new file is created. 
  330.         'APPL',                     // TYPE for new file
  331.         'ttxt',                     // CREATOR for new file
  332.         
  333.         0,                             // finder attribute flags
  334.                                     // filled by ScriptCheck is value is 0
  335.         
  336.         1,                              // creation date for new file
  337.         1,                              // modification date for new file
  338.                                     // NOTE: DATE values are filled
  339.                                     // by ScriptCheck if the value is 1
  340.                                             
  341.         0,                             // search proc ID ( 'insp' ), none used
  342.         
  343.         ":System Rules App Example:TeachText • 7.5" // path to target file
  344.         }
  345.     };
  346.  
  347. // source file spec for TeachText application for 7.5
  348. resource 'infs' (10076) {
  349.     'APPL',                    // TYPE for file search
  350.     'ttxt',                    // CREATOR for file search
  351.     
  352.     0x1,                    // creation DATE for source file
  353.                             // ( value of 1, filled in by ScriptCheck
  354.                                 
  355.     noSearchForFile,        // IGNORED in Installer 4.0.x
  356.     TypeCrMustMatch,        // TYPE, CREATOR must match file on install disk
  357.     "Disk 1:TeachText • 7.5"    // PATH to source file        
  358. };
  359.  
  360.  
  361. // target file spec for TeachText application for 7.0
  362. resource 'intf' (10070) {
  363.     format1 {
  364.         noSearchForFile,             // use default search path
  365.         
  366.         TypeCrMustMatch,             // If this is set to TypeCrMustMatch
  367.                                     // then a file with a different type
  368.                                     // and creator than those specified
  369.                                     // below will not be replaced.
  370.                                     // If this is set to TypeCrNeedNotMatch
  371.                                     // then type and creator of an existing
  372.                                     // target file are ignored.
  373.         
  374.         // The Type and Creator fields will be used to set the
  375.         // file's Type and Creator when a new file is created. 
  376.         'APPL',                     // TYPE for new file
  377.         'ttxt',                     // CREATOR for new file
  378.         
  379.         0,                             // finder attribute flags
  380.                                     // filled by ScriptCheck is value is 0
  381.         
  382.         1,                              // creation date for new file
  383.         1,                              // modification date for new file
  384.                                     // NOTE: DATE values are filled
  385.                                     // by ScriptCheck if the value is 1
  386.                                             
  387.         0,                             // search proc ID ( 'insp' ), none used
  388.         
  389.         ":System Rules App Example:TeachText • 7.0" // path to target file
  390.         }
  391.     };
  392.  
  393. // source file spec for TeachText application for 7.0
  394. resource 'infs' (10071) {
  395.     'APPL',                    // TYPE for file search
  396.     'ttxt',                    // CREATOR for file search
  397.     
  398.     0x1,                    // creation DATE for source file
  399.                             // ( value of 1, filled in by ScriptCheck
  400.                                 
  401.     noSearchForFile,        // IGNORED in Installer 4.0.x
  402.     TypeCrMustMatch,        // TYPE, CREATOR must match file on install disk
  403.     "Disk 1:TeachText • 7.0"    // PATH to source file        
  404. };
  405.  
  406.  
  407.  
  408. // target file spec for checking System version on target
  409. resource 'intf' ( kSystemFileTarget ) {
  410.     format1 {
  411.         noSearchForFile,             // use default search path
  412.         
  413.         TypeCrMustMatch,             // If this is set to TypeCrMustMatch
  414.                                     // then a file with a different type
  415.                                     // and creator than those specified
  416.                                     // below will not be found when this
  417.                                     // target spec is referenced from
  418.                                     // within the rules framework.
  419.         
  420.         'zsys',                     // TYPE for file
  421.         'MACS',                     // CREATOR for file
  422.         
  423.         0,                             // finder attribute flags
  424.         
  425.         1,                              // creation date
  426.         1,                              // modification date
  427.                                             
  428.         0,                             // search proc ID ( 'insp' ), none used
  429.         
  430.         "special-macs:System"    // path to target file
  431.         }
  432.     };
  433.